package com.vtech.ws.cxf.client;

import com.vtech.ws.cxf.service.SoapFileService;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 * https://stackoverflow.com/questions/45662142/how-to-properly-integrate-a-cxf-client-into-spring-boot
 *
 * @author houzhiwei
 * @date 2018/9/9 22:22
 */
@Configuration
@ConfigurationProperties(prefix = "webservice.client.address")
public class ClientConfig {

    @Bean("soapFileService")
    public SoapFileService getSoapFileService() {
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(SoapFileService.class);
        factory.setAddress(fileServiceAddr);
        return factory.create(SoapFileService.class);
    }

    private String fileServiceAddr;

    private String hiServiceAddr;

}
